//
//  NetMessage.m
//  LegoClient
//
//  Created by Balazs Faludi on 02.01.10.
//  Copyright 2010 Universität Basel. All rights reserved.
//

#import "NetMessage.h"

@interface NetMessage ()

@property (nonatomic, retain) NSString *body;

@end


@implementation NetMessage

@synthesize body = _body;

#pragma mark -
#pragma mark Constructors & Destructor

- (id)initWithString:(NSString *)string
{
	self = [super init];
	if (self != nil) {
		self.body = string;
	}
	return self;
}

- (id)initWithBytes:(const uint8_t *)bytes length:(NSUInteger)length
{
	self = [super init];
	if (self != nil) {
		NSString *string = [[NSString alloc] initWithBytes:bytes length:length encoding:kNetMessageEncoding];
		self.body = string;
		[string release];
	}
	return self;
}


- (void) dealloc
{
	self.body = nil;
	[super dealloc];
}

#pragma mark -
#pragma mark Getters & Setters

- (const uint8_t *)bytes {
	return [[self.body dataUsingEncoding:kNetMessageEncoding] bytes];
}

- (NSUInteger)length {
	return [[self.body dataUsingEncoding:kNetMessageEncoding] length];
}

- (NSString *)stringValue {
	return self.body;
}

@end
